#ifndef _CCSKELETON_H_
#define _CCSKELETON_H_

#include "CCSpineObject.h"
#include "CCSpineGlobal.h"
#include "CCBone.h"
#include "CCSlot.h"
#include "CCSkin.h"
#include "cocos2d.h"
#include "CCSkeletalAnimation.h"



/**
 * general skeleton model
 */
class CCSkeleton : public CCSpineObject {
public:
	
	/// slot list type
	typedef vector<CCSlot*> SlotPtrList;
	
private:
	/// bone map
	typedef map<const char*, CCBone*, CCSpineGlobal::CCStrPredicate> BoneMap;
	BoneMap m_boneMap;

	/// slot map
	typedef map<const char*, CCSlot*, CCSpineGlobal::CCStrPredicate> SlotMap;
	SlotMap m_slotMap;
    
    /// skin map
    typedef map<const char*, CCSkin*, CCSpineGlobal::CCStrPredicate> SkinMap;
    SkinMap m_skinMap;
    
    // anim map
    typedef map<const char*, CCSkeletalAnimation*, CCSpineGlobal::CCStrPredicate> AnimationMap;
    AnimationMap m_animMap;

	/// slot display list
	SlotPtrList m_slotDisplayList;
    
    Array* _ary;

protected:
	CCSkeleton();

public:
	virtual ~CCSkeleton();
	static CCSkeleton* create();

	/// add a bone, do nothing if bone with same name is existent
	void addBone(CCBone* bone);

	/// add a slot, do nothing if slot with same name is existent
	void addSlot(CCSlot* slot);
    
    /// add a skin, do nothing if skin with same name is existent
    void addSkin(CCSkin* skin);
    
    void addAnim(CCSkeletalAnimation* anim);
	
	/// get root bone
	CCBone* getRootBone();

	/// get bone by name
	CCBone* getBone(const char* name);

	/// get slot by name
	CCSlot* getSlot(const char* name);
    
    /// get skin by name
    CCSkin* getSkin(const char* name);
    
    CCSkeletalAnimation* getAnim(const char* name);
    
    CCSkeletalAnimation* getAnimRandom();
	
	/// get slot display list
	SlotPtrList& getSlotDisplayList() { return m_slotDisplayList; }
};



#endif // __CCSkeleton_h__
